//
//  ChatModel.m
//  QQchat
//
//  Created by cocoazxj@163.com on 15/3/30.
//  Copyright (c) 2015年 handcool. All rights reserved.
//

#import "ChatModel.h"

@implementation ChatModel
- (instancetype)initWithDict:(NSDictionary *)dict
{
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}


+ (instancetype)chatModel:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

- (CGFloat)textH
{
    NSDictionary *d = @{NSFontAttributeName: [UIFont systemFontOfSize:16]};
    CGFloat f = [self.text boundingRectWithSize:CGSizeMake(140, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:d context:nil].size.height;
    _textH = f + 40;
    return _textH;
}

-(CGFloat)textW
{
    NSDictionary *d = @{NSFontAttributeName: [UIFont systemFontOfSize:16]};
    CGFloat f = [self.text boundingRectWithSize:CGSizeMake(140, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:d context:nil].size.width;
    _textW = f;
    return _textW;
}

- (CGFloat)cellH
{
    CGFloat f;
    if(self.textH > 40)
    {
        // 内容的高度，内容的y坐标，底部间隙
        f = self.textH + 40 + 10;
    }
    else
    {
        // 头像的高度，头像的y坐标，底部间隙
        f = 50 + 40 + 10;
    }
    _cellH = f;
    return _cellH;
}
@end
